package com.wiseman.writing;

import java.io.IOException;

import android.app.Activity;
import android.os.Bundle;
import android.widget.GridView;

import com.wiseman.writing.utility.parsedata.CharByClass;

public class StudyActivity extends Activity implements ConstValue {

	GridView mGridView;
	private String mCharsList = new String();
	CharsAdapter mAdapter = null;
	private CharByClass mCharsByClass;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.study_activity);

		int gradeid = getIntent().getIntExtra(GRADE_ID, 0);
		if (gradeid != GRADE_USER_DEFIND) {
			getData();
			mCharsList = mCharsByClass.mCharsByClassList.get(gradeid);
		} else{
			mCharsList = getIntent().getStringExtra(INTENTNAME_CHARLIST);
		}

		mAdapter = new CharsAdapter(this, mCharsList, false);

		mGridView = (GridView) findViewById(R.id.gvChars);
		mGridView.setAdapter(mAdapter);
		mGridView.setOnItemClickListener(mAdapter);

		DomoAd.createBar(this);
	}

	void getData() {
		try {

			mCharsByClass = new CharByClass(getAssets().open("chinese_by_class"));

		} catch (IOException e) {

			e.printStackTrace();
		}

	}

}
